package com.sp.scmdb.serviceImpl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.sp.scmdb.bean.DaySecurityBean;
import com.sp.scmdb.dao.DaySecurityDao;
import com.sp.scmdb.entity.DaySecurity;
import com.sp.scmdb.service.DaySecurityService;
import com.sp.scmdb.service.LogService;

@Service("daySecurityService")
public class DaySecurityServiceImpl implements DaySecurityService {

	private DaySecurityDao daySecurityDao;
	private LogService logs;

	public void setDaySecurityDao(DaySecurityDao daySecurityDao) {
		this.daySecurityDao = daySecurityDao;
	}
	public void setLogs(LogService logs) {
		this.logs = logs;
	}

	@Override
	public String createDaySecurity(DaySecurity daySecurity) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String delDaySecurity(DaySecurity daySecurity) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String editDaySecurity(DaySecurity daySecurity) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public DaySecurity getDaySecurity(String sysId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<DaySecurityBean> getListDaySecurity(String hql) {
		DaySecurityBean daySecurityBean = null;
		DaySecurity daySecurity = null;
		String _hql ="select new DaySecurity(ds.sysId, ds.title, " +
		"ds.createdDate, ds.user, ds.speaker, ds.speakerDate) " +
		"from DaySecurity as ds";
		List<DaySecurity> list = daySecurityDao.queryHql(_hql);
		List<DaySecurityBean> daySecurityList = new ArrayList<DaySecurityBean>();
		
		try {
			for (int i = 0; i < list.size(); i++) {
				daySecurity = list.get(i);
				daySecurityBean = new DaySecurityBean();
				daySecurityBean.setSysId(daySecurity.getSysId());
				daySecurityBean.setTitle(daySecurity.getTitle());
				daySecurityBean.setCreatedDate(daySecurity.getCreatedDate());
				daySecurityBean.setUser(daySecurity.getUser());
				daySecurityBean.setSpeaker(daySecurity.getSpeaker());
				daySecurityBean.setSpeakerDate(daySecurity.getSpeakerDate());
				
				daySecurityList.add(daySecurityBean);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return daySecurityList;
	}

}
